package com.nchu.student_score.controller;

import com.github.pagehelper.PageInfo;
import com.nchu.student_score.dataObject.GradeResult;
import com.nchu.student_score.model.Grade;
import com.nchu.student_score.model.GradeTemp;
import com.nchu.student_score.model.TeachTask;
import com.nchu.student_score.service.GradeService;
import com.nchu.student_score.vo.ResultVo;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/grade")
public class GradeController {
    @Resource
    GradeService gradeService;

    @RequestMapping("getGrades/{currPage}")
    public PageInfo<GradeTemp> getGradeList(@RequestBody GradeTemp gradeTemp,@PathVariable Integer currPage){
        return gradeService.getGradeList(gradeTemp, currPage);
    }

    @RequestMapping("getGradeExcel")
    public ResultVo<GradeTemp> getGradeExcel(@RequestBody GradeTemp gradeTemp){
        return gradeService.getGradeExcel(gradeTemp);
    }

    @RequestMapping("getGradeDetails")//获取学生的一个成绩详情
    public ResultVo<GradeResult> getStuGradeDetails(@RequestBody GradeResult input){
        return gradeService.getStuGradeDetails(input);
    }

    @RequestMapping("getStuGrades/{currPage}")
    public PageInfo<GradeResult> getGradesListByStuId(@RequestBody GradeResult input, @PathVariable Integer currPage){
        return gradeService.getGradesListByStuId(input, currPage);
    }

    @RequestMapping("submitGrades/{submitType}")
    public ResultVo<GradeTemp> submitStudentGrades(@RequestBody TeachTask teachTask, @PathVariable String submitType){
        return gradeService.submitStudentGrades(teachTask,submitType);
    }

    @RequestMapping("getGradeTemps/{currPage}")
    public PageInfo<GradeTemp> getGradeTempList(@RequestBody GradeTemp gradeTemp, @PathVariable Integer currPage){
        return gradeService.getGradeTempList(gradeTemp,currPage);
    }

    @RequestMapping("getGradeTempsExcel")
    public ResultVo<GradeTemp> getGradeTempsExcel(@RequestBody GradeTemp gradeTemp){
        return gradeService.getGradeTempsExcel(gradeTemp);
    }

    @RequestMapping("uploadGradeTempsExcel")
    public ResultVo<GradeTemp> uploadGradeTempsExcel(@RequestBody List<GradeTemp> list){
        return gradeService.uploadGradeTempsExcel(list);
    }

    @RequestMapping("saveGradeTemps")
    public ResultVo<GradeTemp> saveGradeTemps(@RequestBody List<GradeTemp> tempList){
        return gradeService.saveGradeTemps(tempList);
    }
}
